import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma.service';
import { VideoRecord, Prisma } from '@prisma/client';

@Injectable()
export class VideoRecordService {
  constructor(private prisma: PrismaService) {}

  async videoRecord(
    videoRecordWhereUniqueInput: Prisma.VideoRecordWhereUniqueInput,
  ): Promise<VideoRecord | null> {
    return this.prisma.videoRecord.findUnique({
      where: videoRecordWhereUniqueInput,
    });
  }

  async videoRecords(params: {
    skip?: number;
    take?: number;
    cursor?: Prisma.VideoRecordWhereUniqueInput;
    where?: Prisma.VideoRecordWhereInput;
    orderBy?: Prisma.VideoRecordOrderByWithRelationInput;
  }): Promise<VideoRecord[]> {
    const { skip, take, cursor, where, orderBy } = params;
    return this.prisma.videoRecord.findMany({
      skip,
      take,
      cursor,
      where,
      orderBy,
    });
  }

  async createVideoRecord(
    data: Prisma.VideoRecordCreateInput,
  ): Promise<VideoRecord> {
    return this.prisma.videoRecord.create({
      data,
    });
  }

  async updateVideoRecord(params: {
    where: Prisma.VideoRecordWhereUniqueInput;
    data: Prisma.VideoRecordUpdateInput;
  }): Promise<VideoRecord> {
    const { data, where } = params;
    return this.prisma.videoRecord.update({
      data,
      where,
    });
  }

  async deleteVideoRecord(
    where: Prisma.VideoRecordWhereUniqueInput,
  ): Promise<VideoRecord> {
    return this.prisma.videoRecord.delete({
      where,
    });
  }
}
